package com.example.bigevent.pojo;



import com.example.bigevent.validation.ValidationGroup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;

import java.util.Date;

@Data
public class User {
    @NotNull(groups = {ValidationGroup.Update.class})
    private Integer id;//主键ID

    @Pattern(regexp = "^\\S{5,16}$", groups = ValidationGroup.Basic.class)
    @NotEmpty(groups = ValidationGroup.RegisterAndLogin.class)
    private String username;//用户名

    @Pattern(regexp = "^\\S{5,16}$", groups = ValidationGroup.Basic.class)
    @NotEmpty(groups = ValidationGroup.RegisterAndLogin.class)
    @JsonIgnore //spring在将User对象转json时忽略password属性
    private String password;//密码

//    @NotEmpty(groups = {ValidationGroup.Update.class})
    @Pattern(regexp = "^\\S{1,10}$", groups = ValidationGroup.Basic.class)
    private String nickname;//昵称

//    @NotEmpty(groups = {ValidationGroup.Update.class})
    @Email(groups = ValidationGroup.Basic.class)
    private String email;//邮箱

    private String userPic;//用户头像地址

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;//创建时间

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;//更新时间
}
